# GamePanel/Memory test

from javax.swing import JFrame
from com.bensonbasement.snorflux.client import GamePanel
from com.bensonbasement.snorflux.memory import *
from com.bensonbasement.snorflux.utils import Coords

class IDGen(object):
  def __init__(self):
    self.nextID = 1
  def getNextID(self):
    retVal = self.nextID
    self.nextID += 1
    return retVal

idGen = IDGen()

# Build a sample memory
memory = Memory()

for x in range(4):
  for y in range(5):
    coords = Coords(x,y)
    spaceInfo = SpaceInfo(idGen.getNextID(),"floor2","floor",coords,1)
    memory.updateInfo(spaceInfo)
    if x == 0 or x == 3 or y == 0 or y == 4:
      wallInfo = BigEntityInfo(idGen.getNextID(),"wall","wall",spaceInfo.worldElementID)
      memory.updateInfo(wallInfo)
    elif x == 1 and y == 2:
      spacemanInfo = BigEntityInfo(idGen.getNextID(),"spaceman2","spaceman",spaceInfo.worldElementID)
      memory.updateInfo(spacemanInfo)
    if (x == 1 and y == 2) or (x == 1 and y == 3):
      raygunInfo = SmallEntityInfo(idGen.getNextID(),"raygun","raygun",spaceInfo.worldElementID)
      memory.updateInfo(raygunInfo)

level = memory.world.getLevel(1)
panel = GamePanel()
panel.level = level
frame = JFrame("GamePanel Test")
frame.add(panel)
frame.pack()
